import {generate, red, blue, green} from '@ant-design/colors'
import {fileURLToPath} from "node:url";
import path from "node:path";
import * as fs from "fs";

// 主色基准色
const primary = '#FF5722';
// 生成色
const primaryColors = generate(primary);
/*生成主色变量*/
let colorVars = primaryColors.map((color, index) => {
  return `--jvyou-color-primary-${index + 1}: ${color};`
}).join('\n');

colorVars += "\n\n"
/*生成错误色变量*/
colorVars += red.map((color, index) => {
  return `--jvyou-color-error-${index + 1}: ${color};`
}).join('\n');

colorVars += "\n\n"
/*生成成功色变量*/
colorVars += green.map((color, index) => {
  return `--jvyou-color-success-${index + 1}: ${color};`
}).join('\n');

colorVars += "\n\n"

/*生成提示色变量*/
colorVars += blue.map((color, index) => {
  return `--jvyou-color-info-${index + 1}: ${color};`
}).join('\n');

const basePath = fileURLToPath(new URL('../', import.meta.url))
const colorsPath = path.join(basePath, "packages/jvyou-ui-bate/src/style/theme/colors.less")


fs.writeFileSync(colorsPath, `:root {
  ${colorVars}
}`)
